//发送请求获取商品列表渲染table

//请求的路径不需要返回上一级，请求的出发点是在首页，路劲就以首页为准

// utils.fetch('./api/shop/select.php').then(resp => {
//     if (resp.code === 200) {
//         const {
//             list
//         } = resp.body
//         console.log(resp.code);
//         let str = ''
//         list.forEach(shop => {
//             str += `
//         <tr class="danger">
//         <td>${shop.id}</td>
//         <td${shop.name}</td>
//         <td>${shop.price}</td>
//         <td>${shop.num}</td>
//         <td>
//             <button class="btn btn-xs btn-info btn-edit">编辑</button>
//             <button class="btn btn-xs btn-danger btn-del">删除</button>
//             <button class="btn btn-xs btn-success btn-ok">确定</button>
//             <button class="btn btn-xs btn-warning btn-cancel">取消</button>
//         </td>
//         </tr>
//         `

//         });
//         $("#shop-tbody").innerHTML=str
//     }
// })



getDate()
function getDate(){
    $(function(){
        $.get('./api/shop/select.php',resp => {
            var resp=JSON.parse(resp)
            if (resp.code === 200) {
                const {
                    list
                } = resp.body
                let str = ''
                list.map((shop,index) => {
                    str += `
                <tr data-id="${shop.id}">
                <td>${index+1}</td>
                <td><span>${shop.name}</span><input type="text" class="input-name"></td>
                <td><span>${shop.price}</span><input type="text" class="input-price"></td>
                <td><span>${shop.num}</span><input type="text" class="input-num"></td>
                <td>
                    <button class="btn btn-xs btn-info btn-edit">编辑</button>
                    <button class="btn btn-xs btn-danger btn-del">删除</button>
                    <button class="btn btn-xs btn-success btn-ok">确定</button>
                    <button class="btn btn-xs btn-warning btn-cancel">取消</button>
                </td>
                </tr>
                `
        
                });
                $("#shop-tbody").html(str)
            }
        })
    })
}